Fix the rest of the deprecation warnings

Dominik Sander 7 years ago
parent
commit
26e878c61a

+ 3 - 5
Gemfile

@@ -95,17 +95,15 @@ gem 'faraday_middleware', github: 'lostisland/faraday_middleware', branch: 'mast
95 95
 gem 'feed-normalizer'
96 96
 gem 'font-awesome-sass', '~> 4.3.2'
97 97
 gem 'foreman', '~> 0.63.0'
98
-# geokit-rails doesn't work with geokit 1.8.X but it specifies ~> 1.5
99
-# in its own Gemfile.
100 98
 gem 'geokit', '~> 1.8.4'
101
-gem 'geokit-rails', '~> 2.0.1'
99
+gem 'geokit-rails', '~> 2.2.0'
102 100
 gem 'httparty', '~> 0.13'
103 101
 gem 'httmultiparty', '~> 0.3.16'
104 102
 gem 'jquery-rails', '~> 4.2.1'
105 103
 gem 'huginn_agent', '~> 0.4.0'
106 104
 gem 'json', '~> 1.8.1'
107 105
 gem 'jsonpathv2', '~> 0.0.8'
108
-gem 'kaminari', '~> 0.16.1'
106
+gem 'kaminari', '~> 0.16.2'
109 107
 gem 'kramdown', '~> 1.3.3'
110 108
 gem 'liquid', '~> 3.0.3'
111 109
 gem 'mini_magick'
@@ -138,7 +136,7 @@ group :development do
138 136
 
139 137
   if_true(ENV['SPRING']) do
140 138
     gem 'spring-commands-rspec', '~> 1.0.4'
141
-    gem 'spring', '~> 1.6.3'
139
+    gem 'spring', '~> 1.7.2'
142 140
     gem 'spring-watcher-listen', '~> 2.0.0'
143 141
   end
144 142
 

+ 8 - 8
Gemfile.lock

@@ -210,7 +210,7 @@ GEM
210 210
     formatador (0.2.5)
211 211
     geokit (1.8.5)
212 212
       multi_json (>= 1.3.2)
213
-    geokit-rails (2.0.1)
213
+    geokit-rails (2.2.0)
214 214
       geokit (~> 1.5)
215 215
       rails (>= 3.0)
216 216
     globalid (0.3.7)
@@ -277,7 +277,7 @@ GEM
277 277
     jsonpathv2 (0.0.8)
278 278
       multi_json
279 279
     jwt (1.4.1)
280
-    kaminari (0.16.1)
280
+    kaminari (0.16.3)
281 281
       actionpack (>= 3.0.0)
282 282
       activesupport (>= 3.0.0)
283 283
     kgio (2.10.0)
@@ -311,7 +311,7 @@ GEM
311 311
     mini_portile2 (2.1.0)
312 312
     minitest (5.9.0)
313 313
     mqtt (0.3.1)
314
-    multi_json (1.11.2)
314
+    multi_json (1.12.1)
315 315
     multi_xml (0.5.5)
316 316
     multipart-post (2.0.0)
317 317
     mysql2 (0.3.20)
@@ -495,7 +495,7 @@ GEM
495 495
     slop (3.6.0)
496 496
     spectrum-rails (1.3.4)
497 497
       railties (>= 3.1)
498
-    spring (1.6.3)
498
+    spring (1.7.2)
499 499
     spring-commands-rspec (1.0.4)
500 500
       spring (>= 0.9.1)
501 501
     spring-watcher-listen (2.0.0)
@@ -567,7 +567,7 @@ GEM
567 567
     webmock (1.17.4)
568 568
       addressable (>= 2.2.7)
569 569
       crack (>= 0.3.2)
570
-    websocket-driver (0.6.3)
570
+    websocket-driver (0.6.4)
571 571
       websocket-extensions (>= 0.1.0)
572 572
     websocket-extensions (0.1.2)
573 573
     wunderground (1.2.0)
@@ -613,7 +613,7 @@ DEPENDENCIES
613 613
   forecast_io (~> 2.0.0)
614 614
   foreman (~> 0.63.0)
615 615
   geokit (~> 1.8.4)
616
-  geokit-rails (~> 2.0.1)
616
+  geokit-rails (~> 2.2.0)
617 617
   google-api-client
618 618
   guard (~> 2.13.0)
619 619
   guard-livereload (~> 2.5.1)
@@ -627,7 +627,7 @@ DEPENDENCIES
627 627
   jquery-rails (~> 4.2.1)
628 628
   json (~> 1.8.1)
629 629
   jsonpathv2 (~> 0.0.8)
630
-  kaminari (~> 0.16.1)
630
+  kaminari (~> 0.16.2)
631 631
   kramdown (~> 1.3.3)
632 632
   letter_opener_web (~> 1.3.0)
633 633
   liquid (~> 3.0.3)
@@ -666,7 +666,7 @@ DEPENDENCIES
666 666
   shoulda-matchers
667 667
   slack-notifier (~> 1.0.0)
668 668
   spectrum-rails
669
-  spring (~> 1.6.3)
669
+  spring (~> 1.7.2)
670 670
   spring-commands-rspec (~> 1.0.4)
671 671
   spring-watcher-listen (~> 2.0.0)
672 672
   string-scrub

+ 3 - 3
app/controllers/admin/users_controller.rb

@@ -38,7 +38,7 @@ class Admin::UsersController < ApplicationController
38 38
   end
39 39
 
40 40
   def update
41
-    params[:user].except!(:password, :password_confirmation) if params[:user][:password].blank?
41
+    params[:user].extract!(:password, :password_confirmation) if params[:user][:password].blank?
42 42
     @user.assign_attributes(user_params)
43 43
 
44 44
     respond_to do |format|
@@ -84,7 +84,7 @@ class Admin::UsersController < ApplicationController
84 84
   def switch_to_user
85 85
     if current_user != @user
86 86
       old_user = current_user
87
-      sign_in(:user, @user, { bypass: true })
87
+      bypass_sign_in(@user)
88 88
       session[:original_admin_user_id] = old_user.id
89 89
     end
90 90
     redirect_to agents_path
@@ -92,7 +92,7 @@ class Admin::UsersController < ApplicationController
92 92
 
93 93
   def switch_back
94 94
     if session[:original_admin_user_id].present?
95
-      sign_in(:user, User.find(session[:original_admin_user_id]), { bypass: true })
95
+      bypass_sign_in(User.find(session[:original_admin_user_id]))
96 96
       session.delete(:original_admin_user_id)
97 97
     else
98 98
       redirect_to(root_path, alert: 'You must be an admin acting as a different user to do that.') and return

+ 1 - 1
app/controllers/agents/dry_runs_controller.rb

@@ -18,7 +18,7 @@ module Agents
18 18
       if agent = current_user.agents.find_by(id: params[:agent_id])
19 19
         # POST /agents/:id/dry_run
20 20
         if attrs.present?
21
-          attrs.merge!(memory: agent.memory)
21
+          attrs = attrs.merge(memory: agent.memory)
22 22
           type = agent.type
23 23
           agent = Agent.build_for_type(type, current_user, attrs)
24 24
         end

+ 2 - 2
app/controllers/agents_controller.rb

@@ -196,9 +196,9 @@ class AgentsController < ApplicationController
196 196
     build_agent
197 197
 
198 198
     if @agent.validate_option(params[:attribute])
199
-      render text: 'ok'
199
+      render plain: 'ok'
200 200
     else
201
-      render text: 'error', status: 403
201
+      render plain: 'error', status: 403
202 202
     end
203 203
   end
204 204
 

+ 2 - 4
app/controllers/application_controller.rb

@@ -12,10 +12,8 @@ class ApplicationController < ActionController::Base
12 12
     render template: 'application/undefined_agents'
13 13
   end
14 14
 
15
-  def redirect_back(fallback_path, *args)
16
-    redirect_to :back, *args
17
-  rescue ActionController::RedirectBackError
18
-    redirect_to fallback_path, *args
15
+  def redirect_back(fallback_path, **args)
16
+    super(fallback_location: fallback_path, **args)
19 17
   end
20 18
 
21 19
   protected

+ 5 - 5
app/controllers/web_requests_controller.rb

@@ -27,17 +27,17 @@ class WebRequestsController < ApplicationController
27 27
         content, status, content_type = agent.trigger_web_request(request)
28 28
 
29 29
         if content.is_a?(String)
30
-          render :text => content, :status => status || 200, :content_type => content_type || 'text/plain'
30
+          render plain: content, :status => status || 200, :content_type => content_type || 'text/plain'
31 31
         elsif content.is_a?(Hash)
32 32
           render :json => content, :status => status || 200
33 33
         else
34 34
           head(status || 200)
35 35
         end
36 36
       else
37
-        render :text => "agent not found", :status => 404
37
+        render plain: "agent not found", :status => 404
38 38
       end
39 39
     else
40
-      render :text => "user not found", :status => 404
40
+      render plain: "user not found", :status => 404
41 41
     end
42 42
   end
43 43
 
@@ -50,9 +50,9 @@ class WebRequestsController < ApplicationController
50 50
           agent.trigger_web_request(request)
51 51
         end
52 52
       }
53
-      render :text => "ok"
53
+      render plain: "ok"
54 54
     else
55
-      render :text => "user not found", :status => :not_found
55
+      render plain: "user not found", :status => :not_found
56 56
     end
57 57
   end
58 58
 end

+ 0 - 3
config/application.rb

@@ -39,9 +39,6 @@ module Huginn
39 39
     # like if you have constraints or database-specific column types
40 40
     # config.active_record.schema_format = :sql
41 41
 
42
-    # Do not swallow errors in after_commit/after_rollback callbacks.
43
-    config.active_record.raise_in_transactional_callbacks = true
44
-
45 42
     config.active_job.queue_adapter = :delayed_job
46 43
   end
47 44
 end

+ 7 - 8
config/initializers/silence_worker_status_logger.rb

@@ -1,10 +1,9 @@
1
-Rails::Rack::Logger.class_eval do
2
-  def call_with_silence_worker_status(env)
3
-    previous_level = Rails.logger.level
4
-    Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/worker_status}
5
-    call_without_silence_worker_status(env)
6
-  ensure
7
-    Rails.logger.level = previous_level
1
+module SilencedLogger
2
+  def call(env)
3
+    return super(env) if env['PATH_INFO'] !~ %r{^/worker_status}
4
+    Rails.logger.silence(Logger::ERROR) do
5
+      super(env)
6
+    end
8 7
   end
9
-  alias_method_chain :call, :silence_worker_status
10 8
 end
9
+Rails::Rack::Logger.send(:prepend, SilencedLogger)

+ 1 - 1
spec/rails_helper.rb

@@ -66,7 +66,7 @@ RSpec.configure do |config|
66 66
 
67 67
   config.render_views
68 68
 
69
-  config.include Devise::TestHelpers, type: :controller
69
+  config.include Devise::Test::ControllerHelpers, type: :controller
70 70
   config.include SpecHelpers
71 71
   config.include Delorean
72 72
 end